-#
  Copyright 2008 Garth Williams

  This file is part of CommandPost.

  CommandPost is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  CommandPost is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with CommandPost.  If not, see <http://www.gnu.org/licenses/>.


!!! XML
!!! Strict
%html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
  %head
    %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=iso-8859-1"}
    = stylesheet_link_tag "master"
    = javascript_include_tag :defaults
    %title= h "#{AppConfig.project_name} / #{controller.controller_name.gsub('_', ' ').gsub(/^[a-z]|\s+[a-z]/) { |a| a.upcase }} / CommandPost"
  %body
    #pagebody
      #header
        #signout
          -if logged_in?
            = "Signed in as #{link_to(h(current_user.name), user_path(current_user))} / "
            = link_to 'Sign out', session_path, :method => :delete
          -else
            = link_to 'Sign in', new_session_path
        %span#slogan
          = h AppConfig.tag_line_one
          %br
          = h AppConfig.tag_line_two

        %ul
          %li{:id => if @section == 'home' then 'current' else '' end}
            =link_to '<span>Home</span>', :controller => 'home_screen'
          %li{:id => if @section == 'reports' then 'current' else '' end}
            =link_to '<span>Reports</span>', :controller => 'reports'
          %li{:id => if @section == 'milestones' then 'current' else '' end}
            =link_to '<span>Milestones</span>', :controller => 'milestones'
          -if logged_in? and current_user.has_role?('Administrators')
            %li{:id => if @section == 'users' then 'current' else '' end}
              =link_to '<span>Users</span>', :controller => 'users'
            %li{:id => if @section == 'roles' then 'current' else '' end}
              =link_to '<span>Roles</span>', :controller => 'roles'
          -if logged_in? and current_user.has_role?('ReportTypeAdministrators')
            %li{:id => if @section == 'report_types' then 'current' else '' end}
              =link_to '<span>Report Types</span>', :controller => 'report_types'
          %li{:id => if @section == 'logs' then 'current' else '' end}
            =link_to '<span>Logs</span>', :controller => 'logs'

      #header-logo
        #logo
          = h AppConfig.project_name

        %form{:method => "post", :class => "search", :action => "#"}
          %p
            %input.textbox{:name => "search_query", :type => "text"}
            %input.searchbutton{:name => "search", :value => "Search", :type => "submit"}

      #sidebar
        - types = report_types
        - if types.length > 0
          %h1 New Report
          .right-box
            - form_for(Report.new) do |f|
              = f.select :stage_id, types.collect { |type| [type.name, type.first_stage.id] }
              %br
              .align-right
                = f.submit "Create Report", :class => 'button'
        - content = sidebar_content
        %h1=content.title
        .right-box
          =render_text content.body
          -if logged_in? and current_user.has_role?('PageAuthors')
            .align-right
              =link_to 'edit', :controller => 'pages', :action => 'edit', :name => 'sidebar_content'

        %h1 Recent Activity
        .right-box
          %ul.sidemenu
            - for log in latest_logs
              %div
                - if log.subject_id == nil
                  = h log.summary
                - else
                  = link_to h(log.summary), log_link(log)
              .align-right.small
                = h "#{log.created_by.name}, #{render_time_elapsed(log.created_at)}"
          .align-right
            = link_to 'more', :controller => 'logs'
        %br

      #main= yield

    #footer
    #footer-overlay
      #footer-left
        %span#footer-logo
          = link_to '<span class="red">Command</span>Post', 'http://commandpostapp.org'
      #footer-right
        Copyright &copy; 2008 eConcepts Limited
